#ifndef PRETREATMENTHANDLER_H
#define PRETREATMENTHANDLER_H
#include <QVector>
#include <vector>
#include "global.h"

using namespace std;

class PretreatmentHandler
{
public:
    PretreatmentHandler();
    // 检查是否应用特定选项
    static bool shouldApplyOption(const std::vector<ValidationOption>& options, ValidationOption option) {
        return std::find(options.begin(), options.end(), option) != options.end();
    }

    // 获取大小写敏感选项
    static Qt::CaseSensitivity getCaseSensitivity(const std::vector<ValidationOption>& options) {
        if (shouldApplyOption(options, CaseInsensitive)) {
            return Qt::CaseInsensitive;
        }
        return Qt::CaseSensitive;
    }

    // 预处理字符串
    static QString preprocess(const QString& input, const std::vector<ValidationOption>& options) {
        QString result = input;
        if (shouldApplyOption(options, TrimWhitespace)) {
            result = result.trimmed();
        }
        if (shouldApplyOption(options, CaseInsensitive)) {
            result = result.toLower();
        }
        return result;
    }

    // 比较字符串（考虑大小写选项）
    static bool compareStrings(const QString& s1, const QString& s2,
                        const std::vector<ValidationOption>& options) {
        if (shouldApplyOption(options, CaseInsensitive)) {
            return s1.compare(s2, Qt::CaseInsensitive) == 0;
        }
        return s1 == s2;
    }
};

#endif // PRETREATMENTHANDLER_H
